Skip to content

[ADD] estate,estate_account: technical onboarding commit #1285

Open
jupir-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-tuto-server-jupir
Open

[ADD] estate,estate_account: technical onboarding commit #1285
jupir-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-tuto-server-jupir

Conversation

@jupir-odoo
Copy link
Copy Markdown

@jupir-odoo jupir-odoo commented May 19, 2026

[ADD] estate,estate_accountant: technical onboarding commit

Problem:
There is currently no modules to manage real estate businesses in odoo.

Solution:
Implement estate properties, offer, tags, and types models with the associated views.

task-6229399

@robodoo
Copy link
Copy Markdown

robodoo commented May 19, 2026

Pull request status dashboard

@aboo-odoo aboo-odoo self-requested a review May 21, 2026 07:48
@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 07fb131 to 2b8c4ec Compare May 21, 2026 13:47
@jupir-odoo jupir-odoo changed the title 19.0 tuto server jupir [ADD] estate,estate_accountant: technical onboarding commit May 21, 2026
@jupir-odoo
Copy link
Copy Markdown
Author

@aboo-odoo kind reminder :D

@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 2b8c4ec to 5c36dbc Compare May 21, 2026 14:19
@jupir-odoo jupir-odoo changed the title [ADD] estate,estate_accountant: technical onboarding commit [ADD] estate,estate_account: technical onboarding commit May 21, 2026
Copy link
Copy Markdown

@aboo-odoo aboo-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phenomenal work 🥳 I'm being extra-picky so that I can transmit as much information as possible. If there is anything you disagree with, please share it without fear.

Some comments apply at several places but I've only written it once to save some time and to not cumbersome the PR, when you check and update according to one of my comment, check that this comment does not apply elsewhere before moving to the next one 😄

A generic comment:

  • your PR/commit body could be a little more exhaustive a good template is to follow is
STEPS to reproduce the bug (only for bugfixes)
PROBLEM - what is the problem 
GOAL - what do we want to achieve
SOLUTION - how did we achieve it 

task-XXXXXX

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a Model attribute order should be:

  1. Private attributes (_name, _description, _inherit, …)
  2. Default method and default_get
  3. Field declarations
  4. SQL constraints and indexes
  5. Compute, inverse and search methods in the same order as field declaration
  6. Selection method (methods used to return computed values for selection fields)
  7. Constrains methods (@api.constrains) and onchange methods (@api.onchange)
  8. CRUD methods (ORM overrides)
  9. Action methods
  10. And finally, other business methods.

Comment thread estate/models/estate_property.py Outdated
copy=False, default=datetime.today() + relativedelta(months=3)
)
expected_price = fields.Float(required=True)
_expected_price_constraint = models.Constraint(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two constraints should be just after the _order attribute 😄

Comment thread estate/models/estate_property.py Outdated


class EstatePropery(models.Model):
_name = "estate.property"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a tacit convention that strings viewed by the users are surrounded by ", otherwise it is '

Suggested change
_name = "estate.property"
_name = 'estate.property'

Comment thread estate/models/estate_property.py Outdated
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string="Orientation",
selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider selection and a kind of dictionary, for dictionaries, you would write the keys in lower letters

Suggested change
selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")],
selection=[('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")],

Also, don't hesitate to be exhaustive in your name; estate.garden_orientation = 'north' is a bit clearer than estate.garden_orientation = 'n'

Comment thread estate/models/estate_property.py Outdated
default="new",
)

def action_cancel_property(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self is a recordset, i.e. a collection of records. Your method would failed if called on several records when trying to perform self.state.

Currently, through the UI, you cannot trigger the error, but from the command line or a server action, users could get the traceback.

side note: you can run odoo in terminal mode by adding shell after odoo-bin: python odoo-bin shell --addons-path .... From there, you could perform

estates = self.env['estate.property'].create([{'name': 'TEST1', ADD the other relevant key-value pairs}, {'name': 'TEST2', ADD the other relevant key-value pairs}])
estates.action_cancel_property()  # This should trigger the traceback

There are two ways to solve the issue:

  • begin your method with self.ensure_one(), quite self explanatory
  • or use a for loop like in _compute methods

Comment thread estate/models/estate_property_offer.py Outdated
)

def action_accept(self):
if self.property_id.state == "sold":
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the property is cancelled ?

Comment thread estate/models/estate_property_offer.py Outdated
Comment on lines +41 to +42
@api.model
def create(self, vals):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be preferable that you create the records in a batch rather than one by one, better performances 😄

Suggested change
@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):

Comment thread estate/models/estate_property_offer.py Outdated
if float_compare(property.best_price, record["price"], 2) == 1:
raise UserError("You already have a higher offer")

if hasattr(property, "state"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property model always has the state attribute (you defined it as field), in what scenario could you not have one ?

Comment thread estate/__manifest__.py Outdated
],
"installable": True,
"application": True,
"author": "Julien (jupir)",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything you create for Odoo belongs to "Odoo S.A." hehe

Suggested change
"author": "Julien (jupir)",
"author": "Odoo S.A.",

Comment thread estate/models/estate_property_offer.py Outdated
Comment on lines +57 to +62
delta = timedelta(days=offer.validity)
offer.date_deadline = (
offer.create_date.date() + delta
if offer.create_date
else today() + delta
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively (one-liner)

Suggested change
delta = timedelta(days=offer.validity)
offer.date_deadline = (
offer.create_date.date() + delta
if offer.create_date
else today() + delta
)
offer.date_deadline = (offer.create_date or today()).date() + timedelta(days=offer.validity)

@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 5c36dbc to 4fd2d3b Compare May 22, 2026 11:30
Comment thread estate/models/estate_property.py Outdated
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(
copy=False, default=datetime.today() + relativedelta(months=3)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just noticed an issue here:

when declaring the default value like so, it will get computed once you start the database. The computed value will then be used until your database is restarted. This means that if you start your db today 26/05 and let it run for a month and that, on the 26/06 you create a new property record, the default date_availibility will be 26/08 (mai + 3 month) while we expect it to be 26/09 (june + 3 month).

To make the default value recomputed at each call; you need to call a function

@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 4fd2d3b to 9001c34 Compare May 26, 2026 15:11
Problem:
There is currently no modules to manage real estate businesses in odoo.

Solution:
Implement estate properties, offer, tags, and types models with the
associated views.

task-6229399
@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 9001c34 to 985deb6 Compare May 27, 2026 07:31
@jupir-odoo
Copy link
Copy Markdown
Author

Hello @aboo-odoo, j'ai appliqué tes conseils. Merci beaucoup. J'ai aussi fait le tuto sur les unit tests. Je ne sais pas si tu préfères que je les push aussi ici ou que je crée une deuxième PR. Merci d'avance !

@jupir-odoo jupir-odoo self-assigned this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants